from sqlalchemy import Column, DateTime, Integer, String, ForeignKey
from sqlalchemy.sql import func
from base import Base


class Files(Base):
    __tablename__ = 'files'

    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键ID')
    user_type = Column(Integer, nullable=False, comment='上传者类型，1 管理员 2 用户')
    user_id = Column(Integer, nullable=False, comment='对应用户id')
    file_url = Column(String(255), nullable=False, comment='文件URL')
    type = Column(String(50), nullable=False, default='local', comment='存储方式，local, oss, qiniu')
    file_type = Column(Integer, nullable=False, default=1, comment='文件类型，1 Excel 2 CSV')
    name = Column(String(255), nullable=False, comment='文件名字')
    ext = Column(String(50), nullable=False, comment='扩展名')
    file_size = Column(Integer, nullable=True, comment='文件大小')
    deleted_at = Column(DateTime(timezone=True), nullable=True, comment='删除时间')
    created_at = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')
    updated_at = Column(DateTime(timezone=True), onupdate=func.now(), comment='更新时间')
